/* style.css (Combined Light & Dark Theme - Final & Patched Version) */
/* Light theme is default. Dark theme is activated by adding a '.dark-theme' class to '.favorites-modal-dialog' and '.context-messages-container'. */

/* --- Hide scrollbars ONLY within the plugin's components --- */
#favoritesModal ::-webkit-scrollbar,
#context-messages-frame ::-webkit-scrollbar {
    display: none !important;
}
#favoritesModal *,
#context-messages-frame * {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}

/* --- Animation --- */
@keyframes favFadeIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes favoritesItemSlideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInMessage { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* --- Modal Backdrop --- */
#favoritesModal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ================================================================== */
/*                      LIGHT THEME (DEFAULT)                         */
/* ================================================================== */

/* --- Modal Dialog (LIGHT) --- */
.favorites-modal-dialog {
    background: rgba(255, 255, 255, 1) !important;
    color: #333 !important;
    border: 1px solid rgba(221, 221, 221, 0.5) !important;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    width: 900px;
    max-width: 95vw;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    z-index: 10001;
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.favorites-modal-dialog.visible {
    opacity: 1;
    transform: scale(1);
}

/* --- Modal Header (LIGHT) --- */
.favorites-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 1) !important;
    gap: 10px;
}
/* --- Modal Header (LIGHT) --- */
.favorites-sidebar-toggle {
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    padding: 0 !important;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    object-fit: cover;
    transition: transform 0.4s ease-out !important;
    transform: rotate(0deg);
    flex-shrink: 0;

    /* --- 新增：修复移动端点击时的方形背景 --- */
    -webkit-tap-highlight-color: transparent; /* 关键修复：移除移动端点击高亮效果 */
    outline: none;                           /* 额外保险：确保在任何状态下都没有轮廓 */
    backface-visibility: hidden;             /* 提升动画渲染性能，让浏览器使用GPU加速，防止闪烁 */
}
.favorites-modal-dialog:not(.sidebar-closed) .favorites-sidebar-toggle {
    transform: rotate(360deg) !important;
}
.favorites-modal-title {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    flex-grow: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: transparent !important;
    background: -webkit-linear-gradient(120deg, #bd34fe, #41d1ff) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    user-select: none;
}

/* --- Search Bar (LIGHT) --- */
.favorites-search-container { display: flex; align-items: center; justify-content: flex-end; position: relative; width: 0px; height: 40px; transition: width 0.3s ease-in-out; }
.favorites-search-container.expanded { width: 250px; }
.favorites-search-icon, .favorites-search-filter { cursor: pointer; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute; top: 0; z-index: 2; font-size: 13px; }
.favorites-search-icon { color: #555 !important; width: 0px; right: 0; z-index: 3; transition: opacity 0.2s ease; }
.favorites-search-filter { color: #555 !important; width: 40px; left: 0; opacity: 0; pointer-events: none; transition: color 0.2s ease, opacity 0.3s ease; }
.favorites-search-container.expanded .favorites-search-icon { opacity: 0; pointer-events: none; }
.favorites-search-container.expanded .favorites-search-filter { opacity: 1; pointer-events: auto; }
.favorites-search-filter.active { color: #41d1ff !important; }
#favoritesModal .favorites-search-input { background-color: white !important; color: #333 !important; box-sizing: border-box; width: 100%; height: 36px; padding: 6px 15px 6px 40px; border: 1px solid #ddd !important; border-radius: 20px; font-size: 14px; outline: none; position: absolute; right: 0; top: 2px; opacity: 0; transform-origin: right; transform: scaleX(0); transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none; z-index: 1; }
#favoritesModal .favorites-search-container.expanded .favorites-search-input { opacity: 1; transform: scaleX(1); pointer-events: auto; }
#favoritesModal .favorites-search-input:focus {
    border-color: rgba(216, 168, 231, 0.95) !important;
}

.favorites-modal-close-x { background: transparent !important; border: none !important; color: #555 !important; font-size: 28px; font-weight: 300; cursor: pointer; padding: 8px; line-height: 1; transition: all 0.2s ease; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.favorites-modal-close-x:hover { color: #000 !important; transform: rotate(90deg); }

/* --- Modal Body --- */
.favorites-modal-body { padding: 0; overflow-y: hidden; flex-grow: 1; display: flex; min-height: 0; }

/* --- Two-Panel Layout (LIGHT) --- */
.favorites-chat-list-panel { width: 195px !important; flex-shrink: 0; border-right: 1px solid rgba(0, 0, 0, 0.1) !important; display: flex; flex-direction: column; overflow: hidden; transition: width 0.3s ease, margin-left 0.3s ease, opacity 0.3s ease; background: rgba(255, 255, 255, 0.95) !important; }
.favorites-modal-dialog.sidebar-closed .favorites-chat-list-panel { width: 0 !important; margin-left: -1px; border-right: none !important; opacity: 0; pointer-events: none; }
.favorites-chat-list-items { overflow-y: auto; padding: 8px; flex-grow: 1; }
.favorites-chat-list-item { padding: 10px 12px; cursor: pointer; border-radius: 6px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; transition: background-color 0.2s ease, color 0.2s ease; color: #333 !important; }
.favorites-chat-list-item:hover { background-color: rgba(0, 0, 0, 0.05) !important; }
.favorites-chat-list-item.active { background-color: rgb(216, 168, 231,0.45) !important; font-weight: 600; color: #fff !important; }
.chat-list-item-name { flex-grow: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 !important; }
.chat-list-item-count { flex-shrink: 0; font-size: 0.8em; padding: 0 !important; background: none !important; color: inherit !important; }
.favorites-chat-list-item.active .chat-list-item-count { color: #fff !important; }
.favorites-main-panel { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; background: rgba(255, 255, 255, 1) !important; }

/* --- Favorites List & Items (LIGHT) --- */
.favorites-list { overflow-y: auto; padding: 16px; flex-grow: 1; display: flex; flex-direction: column; gap: 12px; }
.favorites-empty { text-align: center; color: #888 !important; padding: 60px 20px; font-style: italic; margin: auto; }
.favorite-item { background: rgba(0, 0, 0, 0.02) !important; border: 1px solid rgba(0, 0, 0, 0.1) !important; border-radius: 12px; padding: 8px !important; animation: favoritesItemSlideIn 0.4s ease-out; transition: all 0.3s ease; position: relative; display: flex; flex-direction: column; }
.favorite-item.role-ai:hover { border-color: rgba(155, 89, 182, 0.5) !important; background: rgba(0, 0, 0, 0.04) !important; }
.favorite-item.role-user:hover { border-color: rgba(0, 127, 255, 1) !important; background: rgba(0, 127, 255, 0.05) !important; }
.fav-header-info { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; gap: 10px; }
.fav-note-content { font-style: italic; font-size: 14px; word-wrap: break-word; text-align: left; flex-grow: 1;}
.fav-meta-cluster { display: flex; align-items: baseline; gap: 8px; flex-shrink: 0; text-align: right; }
.fav-floor-number, .fav-send-date { font-size: 12px; color: inherit !important; white-space: nowrap; }
.fav-preview { margin-bottom: 12px; line-height: 1.5; max-height: 200px; overflow-y: auto; word-wrap: break-word; white-space: normal; font-size: 14px; color: #333 !important; }
.fav-preview.deleted { color: #ff3a3a !important; font-style: italic; }

/* NOTE CONTENT THEME FIX */
.favorite-item.role-ai .fav-note-content { color: rgba(216, 168, 231, 0.7) !important; }
.favorite-item.role-user .fav-note-content { color: rgba(41, 182, 246, 0.35) !important; }


/* Code block styles (LIGHT) - Scoped to prevent pollution */
#favoritesModal .favorites-modal-dialog:not(.dark-theme) .fav-preview pre,
#context-messages-frame .context-messages-container:not(.dark-theme) .context-message-text pre {
    color: rgba(58, 58, 58, 1) !important; background: rgba(0, 0, 0, 0.05) !important; border: none !important; padding: 10px !important; margin: 5px 0 !important; font-family: monospace !important; white-space: pre-wrap !important; overflow-x: auto !important; word-break: break-all; display: block !important; width: 100% !important; box-sizing: border-box !important; border-radius: 4px !important;
}
/* Quote styles - Scoped to prevent pollution */
#favoritesModal .fav-preview blockquote, #favoritesModal .fav-preview q, 
#favoritesModal .context-message-text blockquote, #favoritesModal .context-message-text q,
#context-messages-frame .fav-preview blockquote, #context-messages-frame .fav-preview q, 
#context-messages-frame .context-message-text blockquote, #context-messages-frame .context-message-text q { 
    color: var(--SmartThemeQuoteColor) !important; 
}
/* Q tag reset - Scoped to prevent pollution */
#favoritesModal q, #favoritesModal q::before, #favoritesModal q::after,
#context-messages-frame q, #context-messages-frame q::before, #context-messages-frame q::after { 
    content: none !important; quotes: none !important; margin: 0 !important; padding: 0 !important; 
}

/* --- Action Buttons (LIGHT) --- */
.fav-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 !important; margin: 0 !important; margin-top: auto; flex-wrap: wrap; }
.fav-actions i { cursor: pointer; padding: 0 !important; margin: 0 !important; border-radius: 50%; transition: color 0.2s; font-size: 1em; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.fav-actions i:hover { background-color: transparent !important; }
.favorite-item.role-ai .fav-actions i:hover { color: rgba(155, 89, 182, 1) !important; }
.favorite-item.role-user .fav-actions i:hover { color: rgba(0, 127, 255, 1) !important; }
.fav-actions .fa-expand:hover { color: #2ecc71 !important; }

/* FAV HEADER & ACTIONS COLORING (LIGHT THEME) */
.favorite-item.role-ai .fav-header-info, .favorite-item.role-ai .fav-actions i { color: rgba(216, 168, 231, 0.35) !important; }
.favorite-item.role-user .fav-header-info, .favorite-item.role-user .fav-actions i { color: rgba(0, 127, 255, 0.35) !important; }


/* --- Pagination (LIGHT) --- */
.favorites-pagination { display: flex; justify-content: center; align-items: center; margin: 15px 0 5px 0; gap: 10px; flex-shrink: 0; color: #555 !important; }
.favorites-pagination .menu_button { width: auto; padding: 5px 10px; font-size: 0.9em; }

/* --- Misc Plugin Styles --- */
.favorite-toggle-icon { cursor: pointer; transition: opacity var(--animation-duration-2x) ease-in-out; filter: drop-shadow(0px 0px 2px black); opacity: 0.3; padding: 1px 3px; display: inline-flex; align-items: center; justify-content: center; }
.favorite-toggle-icon:hover { opacity: 1; }
.favorite-toggle-icon i.fa-solid { color: yellow !important; }
        
/* --- Context Viewer Styles (LIGHT) --- */
.context-messages-frame { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0); z-index: 10000; display: flex; align-items: center; justify-content: center; opacity: 0; transition: all 0.3s ease; backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px); pointer-events: none; }
.context-messages-frame.visible { opacity: 1; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); pointer-events: auto; }
.context-messages-container { position: relative; /* For scrollbar positioning */ width: 900px; max-width: 95vw; height: 85vh; background: #ffffff !important; border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); overflow: hidden; display: flex; flex-direction: column; transform: translateY(20px); opacity: 0; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.context-messages-frame.visible .context-messages-container { transform: translateY(0); opacity: 1; }
.context-messages-header { background: #f7f7f7 !important; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e0e0e0 !important; }
.context-title { font-size: 1.2em; font-weight: bold; color: #333 !important; }
.context-close-btn { cursor: pointer; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background-color: transparent !important; transition: background-color 0.2s ease; }
.context-close-btn:hover { background-color: #e0e0e0 !important; }
.context-close-btn i { color: #555 !important; font-size: 16px; }
.context-messages-content { padding: 10px 0; overflow-y: auto; flex-grow: 1; display: flex; flex-direction: column; gap: 20px; }
.context-message-wrapper { display: flex; align-items: flex-start; gap: 12px; animation: fadeInMessage 0.3s ease-out forwards; width: 90%; margin-left: auto; margin-right: auto; }
.context-message-avatar { flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; overflow: hidden; }
.user-message .context-message-avatar { display: none; }
.context-message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.context-message-bubble { padding: 0; flex-grow: 1; }
.context-message-name { font-weight: bold; margin-bottom: 6px; color: #333 !important; }
.user-message .context-message-name { display: none; }
.context-message-text { line-height: 1.6; word-wrap: break-word; color: #555 !important; white-space: pre-wrap; }
.context-message-text p { margin: 0; }
.user-message .context-message-bubble { background-color: #e9eef3 !important; padding: 12px 16px; border-radius: 12px; }

/* CUSTOM CONTEXT SCROLLBAR */
.k-scrollerbar {
    left: 0;
    top: 0;
    background-color: rgba(216, 168, 231, 0.95);
    border-radius: .3em;
    position: absolute;
    z-index: 200;
    width: 5px;
    height: 0;
    opacity: 0;
    /* Transition opacity and the growing height */
    transition: opacity 0.5s ease-out, height 0.1s linear;
    cursor: pointer;
}

/* --- Preview Mode UI Styles (LIGHT) --- */
#favorites-preview-toggle:hover { 
    transform: translateY(-50%) scale(1.1); /* Combine transforms */
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); 
}
#favorites-preview-toggle:active { 
    transform: translateY(-50%) scale(1.05); /* Combine transforms */
}

#favorites-preview-toggle { display: none; position: fixed; top: 0; bottom: 0; margin-top: 350px; margin-bottom: auto; right: 20px; z-index: 10002; width: 48px; height: 48px; background-color: rgba(255, 255, 255, 0.9) !important; color: #333 !important; border: 1px solid rgba(0, 0, 0, 0.1) !important; border-radius: 50%; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); cursor: pointer; align-items: center; justify-content: center; font-size: 20px; transition: transform 0.2s ease, box-shadow 0.2s ease; }



/* --- Preview Mode UI Styles (Managed by parent class) --- */


/* 2. 定义退出预览按钮 (底部红色按钮) 的外观 */
#favorites-preview-exit-button {
    z-index: 10002;
    padding: 12px 20px !important;
    font-size: 1em !important;
    background-color: #c0392b !important;
    color: white !important;
    border: none !important;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    width: auto;
    max-width: 300px;
    margin: 0 auto; /* 在 flex 容器中水平居中 */
    flex-shrink: 0;
}
#favorites-preview-exit-button:hover {
    background-color: #e74c3c !important;
}

/* 3. 使用状态类控制底部区域的显隐 */
/* 默认状态 (非预览): 隐藏退出按钮，显示输入框 */
#form_sheld > #favorites-preview-exit-button {
    display: none;
}
#form_sheld > #send_form {
    display: flex;
}

/* 预览激活状态: 显示退出按钮，隐藏输入框 */
#form_sheld.star-preview-active {
    display: flex !important;
    justify-content: center;
    align-items: center;
}
#form_sheld.star-preview-active > #send_form {
    display: none !important;
}
#form_sheld.star-preview-active > #favorites-preview-exit-button {
    display: block;
}


/* Final cleanup for all themes - Scoped to prevent pollution */
#favoritesModal div.fav-preview code, #favoritesModal .context-message-text code,
#favoritesModal .favorites-modal-dialog code,
#context-messages-frame div.fav-preview code, #context-messages-frame .context-message-text code,
#context-messages-frame code {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    color: inherit !important;
    font-family: var(--monoFontFamily) !important;
    text-shadow: none !important;
}

@media (max-width: 950px) {
    .context-messages-frame { align-items: flex-start; padding-top: 4vh; padding-bottom: 100vh; }
    .context-messages-container { height: 85vh; }
}

/* ================================================================== */
/*                         DARK THEME OVERRIDES                       */
/* ================================================================== */

/* --- Modal Dialog (DARK) --- */
.dark-theme.favorites-modal-dialog {
    background: rgba(30, 30, 30, 1) !important;
    color: #f0f0f0 !important;
    border: none !important;
}

/* --- Modal Header (DARK) --- */
.dark-theme .favorites-modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    background: transparent !important;
}

/* --- Search Bar (DARK) --- */
.dark-theme .favorites-search-icon, .dark-theme .favorites-search-filter {
    color: #aaa !important;
}
.dark-theme #favoritesModal .favorites-search-input {
    border: 1px solid #444 !important;
    background-color: #2c2c2e !important;
    color: #f0f0f0 !important;
}

.dark-theme #favoritesModal .favorites-search-input:focus {
    border-color: rgba(216, 168, 231, 0.95) !important;
}

.dark-theme .favorites-search-filter.active {
    color: rgba(216, 168, 231, 0.95) !important;
}
.dark-theme .favorites-modal-close-x {
    color: #aaa !important;
}
.dark-theme .favorites-modal-close-x:hover {
    color: #fff !important;
}

/* --- Two-Panel Layout (DARK) --- */
.dark-theme .favorites-chat-list-panel {
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
    background: rgba(40, 42, 45, 0.7) !important;
}
.dark-theme.favorites-modal-dialog.sidebar-closed .favorites-chat-list-panel {
    border-right: none !important;
}
.dark-theme .favorites-chat-list-item {
    color: #f0f0f0 !important;
}
.dark-theme .favorites-chat-list-item:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}
.dark-theme .favorites-chat-list-item.active {
    background-color: rgb(216, 168, 231, 0.95) !important;
    color: #000000 !important;
}
.dark-theme .favorites-chat-list-item.active .chat-list-item-count {
    color: #000000 !important;
}
.dark-theme .favorites-main-panel {
    background: transparent !important;
}

/* --- Favorites List & Items (DARK) --- */
.dark-theme .favorite-item {
    background: rgba(40, 40, 40, 0.7) !important;
    border: 1px solid transparent !important;
}
.dark-theme .favorite-item.role-ai:hover {
    border-color: rgba(155, 89, 182, 0.5) !important;
    background: rgba(45, 47, 50, 0.9) !important;
}
.dark-theme .favorite-item.role-user:hover {
    border-color: #b3d8ff !important;
    background: rgba(45, 47, 50, 0.9) !important;
}

.dark-theme .fav-preview {
    color: #e0e0e0 !important;
}
.dark-theme .fav-preview.deleted {
    color: #ff5c5c !important;
}
/* NOTE CONTENT THEME FIX */
.dark-theme .favorite-item.role-user .fav-note-content {
    color: rgba(41, 182, 246, 0.65) !important;
}

/* Code block styles (DARK) - Scoped to prevent pollution */
.dark-theme.favorites-modal-dialog .fav-preview pre,
.dark-theme.context-messages-container .context-message-text pre {
    color: inherit !important;
    background: rgba(0, 0, 0, 0.1) !important;
    border: none !important; 
    padding: 10px !important; 
    margin: 5px 0 !important; 
    font-family: monospace !important; 
    white-space: pre-wrap !important; 
    overflow-x: auto !important; 
    word-break: break-all; 
    display: block !important; 
    width: 100% !important; 
    box-sizing: border-box !important; 
    border-radius: 4px !important;
}
/* --- Action Buttons (DARK) --- */
.dark-theme .fav-actions i:hover { background-color: transparent !important; }
.dark-theme .favorite-item.role-ai .fav-actions i:hover { color: rgba(155, 89, 182, 1) !important; }
.dark-theme .favorite-item.role-user .fav-actions i:hover { color: #b3d8ff !important; }
.dark-theme .fav-actions .fa-expand:hover { color: #2ecc71 !important; }

/* FAV HEADER & ACTIONS COLORING (DARK THEME) */
.dark-theme .favorite-item.role-ai .fav-header-info, .dark-theme .favorite-item.role-ai .fav-actions i { color: rgba(216, 168, 231, 0.7) !important; }
.dark-theme .favorite-item.role-user .fav-header-info, .dark-theme .favorite-item.role-user .fav-actions i { color: rgba(41, 182, 246, 0.65) !important; }

/* --- Pagination (DARK) --- */
.dark-theme .favorites-pagination {
    color: #aaa !important;
}
        
/* --- Context Viewer Styles (DARK) --- */
.dark-theme.context-messages-container {
    background: rgba(30, 30, 30, 1) !important;
}
.dark-theme .context-messages-header {
    background: rgba(30, 30, 30, 1) !important;
    border-bottom: 1px solid #44474b !important;
}
.dark-theme .context-title {
    color: #f0f0f0 !important;
}
.dark-theme .context-close-btn:hover {
    background-color: #44474b !important;
}
.dark-theme .context-close-btn i {
    color: #aaa !important;
}
.dark-theme .context-message-name {
    color: #f0f0f0 !important;
}
.dark-theme .context-message-text {
    color: #e0e0e0 !important;
}
.dark-theme .user-message .context-message-bubble {
    background-color: rgba(40, 40, 40, 0.7) !important;
    padding: 8px 8px !important;
    border-radius: 8px !important;
}

/* --- Preview Mode UI Styles (DARK) --- */
body:has(.dark-theme#favorites-preview-toggle) #favorites-preview-toggle,
.dark-theme #favorites-preview-toggle {
    background-color: rgba(40, 42, 45, 0.9) !important;
    color: #f0f0f0 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* --- FIX: Disable global styles for inputs inside plugin content --- */
#favoritesModal .fav-preview input[type="text"], #favoritesModal .fav-preview input[type="number"], #favoritesModal .fav-preview input:not([type]), #favoritesModal .fav-preview textarea:not([type="search"]),
#context-messages-frame .context-message-text input[type="text"], #context-messages-frame .context-message-text input[type="number"], #context-messages-frame .context-message-text input:not([type]), #context-messages-frame .context-message-text textarea:not([type="search"]) {
    all: revert !important;
    color: inherit !important;
    background-color: transparent !important;
}

/* --- NEW: Custom Avatar Options Menu --- */
#star-options-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10002; /* Must be above the main modal's z-index */
}

.star-options-menu-dialog {
    /* Position is now fixed, JS will handle centering */
    position: fixed;
    z-index: 10003; /* Higher than the overlay */
    
    /* Original appearance styles remain */
    width: 280px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: favFadeIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Light Theme (Default) */
.star-options-menu-dialog {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
}

.star-options-menu-header {
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

.star-options-menu-body {
    padding: 8px;
}

.star-options-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: #444;
    transition: background-color 0.2s ease;
}

.star-options-menu-item:hover {
    background-color: #e9e9e9;
}

.star-options-menu-item i {
    width: 20px;
    text-align: center;
    color: #666;
}

/* Dark Theme Overrides */
.dark-theme.star-options-menu-dialog {
    background-color: #2c2c2e;
    border: 1px solid #444;
}

.dark-theme .star-options-menu-header {
    color: #f0f0f0;
    border-bottom: 1px solid #444;
}

.dark-theme .star-options-menu-item {
    color: #e0e0e0;
}

.dark-theme .star-options-menu-item:hover {
    background-color: #3a3a3c;
}

.dark-theme .star-options-menu-item i {
    color: #aaa;
}
